ARD2  1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
Central_Accel_AL.c File Reference

Abstraction layer to be used for central accelerometer in an airbag. Upper layers shall make requests to the peripheral through this file to avoid peripheral-specific dependencies. More...

#include "derivative.h"
#include "compile_options.h"
#include "Central_Accel_AL.h"
#include "MMA68xx.h"
#include "MMA68xx_Diag.h"
#include "HAL.h"
#include "MailScheduler.h"
#include "DSPI.h"
#include "Utils.h"
#include <limits.h>

Functions

void vfnCAPreSchedulerInit (void)
 Performs default initialization of the central accelerometer as required before launching scheduler (other CA than FSL ones). Entirely empty.
uint32_t u32fnCAInit (void)
 Performs default initialization of the central accelerometer as required before launching scheduler. This initialization includes reset, loading of settings, startup diagnosis and finally the raising of EOP bit.
uint32_t u32fnCAScheduleAccelXY (uint16_t *pu16RawDestination)
 Using the scheduler, programs an XY accelerometer reading.
uint32_t u32fnCAScheduleAccelX (uint16_t *pu16RawDestination)
 Using the scheduler, programs an X accelerometer reading.
uint32_t u32fnCAScheduleAccelY (uint16_t *pu16RawDestination)
 Using the scheduler, programs a Y accelerometer reading.
uint32_t u32fnCAExtractXY (uint16_t *pu16RawSource, uint16_t *pu16FilteredXY)
 Interprets a raw result and transforms it into a 2-word array with X and Y acceleration values.
uint32_t u32fnCAExtractX (uint16_t *pu16RawSource, uint16_t *pu16FilteredX)
 Interprets a raw result and transforms it into a 16-bit word.
uint32_t u32fnCAInitSelfTest (void)
 Performs the self test diagnosis (Pre, ON, Post) at startup for both X and Y axis.
uint32_t u32fnCASelfTest (const uint8_t cu8Axis)
 Performs the self test diagnosis (Pre, ON, Post) for one axis.

Variables

const uint16_t cau16MMA6800ResetSettings []
const uint16_t cau16MMA6800InitSettings []
const uint8_t cu8SizeofMMA6800ResetSettings = N_ELEMENTS(cau16MMA6800ResetSettings)
const uint8_t cu8SizeofMMA6800InitSettings = N_ELEMENTS(cau16MMA6800InitSettings)

Detailed Description

Abstraction layer to be used for central accelerometer in an airbag. Upper layers shall make requests to the peripheral through this file to avoid peripheral-specific dependencies.

Copyright (C) 2011 Freescale Semiconductor Freescale Confidential Proprietary

Author:
Freescale Semiconductor
SASD Automotive
r11515
R54967
Version:
Date:
Warning:
(If needed)

History:


Function Documentation

uint32_t u32fnCAExtractX ( uint16_t *  pu16RawSource,
uint16_t *  pu16FilteredX 
)

Interprets a raw result and transforms it into a 16-bit word.

Parameters:
pu16RawSource,:Array with data directly after the response has been received
pu16FilteredXY,:Pointer to location where the accel value will be stored.
Returns:
Status. Clear when no error found, STATUS_CA_FAILED otherwise.
uint32_t u32fnCAExtractXY ( uint16_t *  pu16RawSource,
uint16_t *  pu16FilteredXY 
)

Interprets a raw result and transforms it into a 2-word array with X and Y acceleration values.

Parameters:
pu16RawSource,:Array with data directly after the response has been received
pu16FilteredXY,:Pointer to a 2-word array where the X and Y results will be stored.
Returns:
Status. Clear when no error found, STATUS_CA_FAILED otherwise.
uint32_t u32fnCAInit ( void  )

Performs default initialization of the central accelerometer as required before launching scheduler. This initialization includes reset, loading of settings, startup diagnosis and finally the raising of EOP bit.

Parameters:
None.
Returns:
Status: Clear when no error found, otherwise is a combination of STATUS_CA_RAW_X_FAILED if Raw data and X axis test1 failed STATUS_CA_OC_X_FAILED if OC data and X axis test1 failed STATUS_CA_RAW_Y_FAILED if Raw data and Y axis test1 failed STATUS_CA_OC_Y_FAILED if OC data and Y axis test1 failed STATUS_CA_RAW_SELF_X_FAILED if Raw data and X axis test2 failed STATUS_CA_OC_SELF_X_FAILED if OC data and X axis test2 failed STATUS_CA_RAW_SELF_Y_FAILED if Raw data and Y axis test2 failed STATUS_CA_OC_SELF_Y_FAILED if OC data and Y axis test2 failed STATUS_CA_RAW_HYST_X_FAILED if Raw data and X axis test3 failed STATUS_CA_OC_HYST_X_FAILED if OC data and X axis test3 failed STATUS_CA_RAW_HYST_Y_FAILED if Raw data and Y axis test3 failed STATUS_CA_OC_HYST_Y_FAILED if OC data and Y axis test3 failed or MAILBOX_CAPACITY_HAS_BEEN_REACHED if SPI transfer failed
uint32_t u32fnCAInitSelfTest ( void  )

Performs the self test diagnosis (Pre, ON, Post) at startup for both X and Y axis.

Returns:
Status: Clear when no error found, otherwise is a combination of STATUS_CA_RAW_X_FAILED if Raw data and X axis test1 failed STATUS_CA_OC_X_FAILED if OC data and X axis test1 failed STATUS_CA_RAW_Y_FAILED if Raw data and Y axis test1 failed STATUS_CA_OC_Y_FAILED if OC data and Y axis test1 failed STATUS_CA_RAW_SELF_X_FAILED if Raw data and X axis test2 failed STATUS_CA_OC_SELF_X_FAILED if OC data and X axis test2 failed STATUS_CA_RAW_SELF_Y_FAILED if Raw data and Y axis test2 failed STATUS_CA_OC_SELF_Y_FAILED if OC data and Y axis test2 failed STATUS_CA_RAW_HYST_X_FAILED if Raw data and X axis test3 failed STATUS_CA_OC_HYST_X_FAILED if OC data and X axis test3 failed STATUS_CA_RAW_HYST_Y_FAILED if Raw data and Y axis test3 failed STATUS_CA_OC_HYST_Y_FAILED if OC data and Y axis test3 failed or MAILBOX_CAPACITY_HAS_BEEN_REACHED if SPI transfer failed
uint32_t u32fnCAScheduleAccelX ( uint16_t *  pu16RawDestination)

Using the scheduler, programs an X accelerometer reading.

Parameters:
pu16RawDestination,:Array where the response from the commands will be stored.
Returns:
Status. Clear when no error found, STATUS_CA_FAILED otherwise.
uint32_t u32fnCAScheduleAccelXY ( uint16_t *  pu16RawDestination)

Using the scheduler, programs an XY accelerometer reading.

Parameters:
pu16RawDestination,:Array where the response from the commands will be stored.
Returns:
Status. Clear when no error found, STATUS_CA_FAILED otherwise.
uint32_t u32fnCAScheduleAccelY ( uint16_t *  pu16RawDestination)

Using the scheduler, programs a Y accelerometer reading.

Parameters:
pu16RawDestination,:Array where the response from the commands will be stored.
Returns:
Status. Clear when no error found, STATUS_CA_FAILED otherwise.
uint32_t u32fnCASelfTest ( const uint8_t  cu8Axis)

Performs the self test diagnosis (Pre, ON, Post) for one axis.

Parameters:
cu8Axis,:Axis along which self test is performed. STATUS_CA_RAW_X_FAILED if Raw data and X axis test1 failed STATUS_CA_OC_X_FAILED if OC data and X axis test1 failed STATUS_CA_RAW_Y_FAILED if Raw data and Y axis test1 failed STATUS_CA_OC_Y_FAILED if OC data and Y axis test1 failed STATUS_CA_RAW_SELF_X_FAILED if Raw data and X axis test2 failed STATUS_CA_OC_SELF_X_FAILED if OC data and X axis test2 failed STATUS_CA_RAW_SELF_Y_FAILED if Raw data and Y axis test2 failed STATUS_CA_OC_SELF_Y_FAILED if OC data and Y axis test2 failed STATUS_CA_RAW_HYST_X_FAILED if Raw data and X axis test3 failed STATUS_CA_OC_HYST_X_FAILED if OC data and X axis test3 failed STATUS_CA_RAW_HYST_Y_FAILED if Raw data and Y axis test3 failed STATUS_CA_OC_HYST_Y_FAILED if OC data and Y axis test3 failed or MAILBOX_CAPACITY_HAS_BEEN_REACHED if SPI transfer failed
void vfnCAPreSchedulerInit ( void  )

Performs default initialization of the central accelerometer as required before launching scheduler (other CA than FSL ones). Entirely empty.

Parameters:
None.
Returns:
Void.

Variable Documentation

const uint16_t cau16MMA6800InitSettings[]
Initial value:
{
  
  (MMA6800_DEVCFG_X | (MMA6800_WRITE_REGISTER << CHAR_BIT) | 0x09u),
  
  (MMA6800_DEVCFG_Y | (MMA6800_WRITE_REGISTER << CHAR_BIT) | 0x0Au),
  
  (MMA6800_ARMCFGX | (MMA6800_WRITE_REGISTER << CHAR_BIT) | 0x33u), 
  
  (MMA6800_ARMCFGY | (MMA6800_WRITE_REGISTER << CHAR_BIT) | 0x33u), 
  
  (MMA6800_ARMT_XP | (MMA6800_WRITE_REGISTER << CHAR_BIT) | 0x05u),
  
  (MMA6800_ARMT_YP | (MMA6800_WRITE_REGISTER << CHAR_BIT) | 0x05u),
  
  (MMA6800_ARMT_XN | (MMA6800_WRITE_REGISTER << CHAR_BIT) | 0x05u),
  
  (MMA6800_ARMT_YN | (MMA6800_WRITE_REGISTER << CHAR_BIT) | 0x05u),
  
  
  (MMA6800_DEVCFG | (MMA6800_WRITE_REGISTER << CHAR_BIT) | 0x15u)}
const uint16_t cau16MMA6800ResetSettings[]
Initial value:
{
  
  (MMA6800_DEVCTL | (MMA6800_WRITE_REGISTER << CHAR_BIT) | CLEAR),
  (MMA6800_DEVCTL | (MMA6800_WRITE_REGISTER << CHAR_BIT) | 0xC0u),
  (MMA6800_DEVCTL | (MMA6800_WRITE_REGISTER << CHAR_BIT) | 0x40u),
  
  (MMA6800_DEVSTAT | (MMA6800_READ_REGISTER << CHAR_BIT) | CLEAR),
  (MMA6800_DEVSTAT | (MMA6800_READ_REGISTER << CHAR_BIT) | CLEAR)}

Initial settings for the existing Central accelerometer. These may not be necessary if the CA changes.